package com.bsi.rd.framework.zuul.pojo;

import javax.servlet.http.HttpServletResponse;

/**
 * 异步提交后返回的内容
 *
 * @author lipan
 */
public class ResultJson {
    /**
     * 状态,1,成功，0.失败
     */
    private String status = "1";
    /**
     * 错误代码,业务系统返回到前端后，判断这个来处理逻辑
     */
    private Integer code;
    /**
     * 错误信息的种类 1为 BusinessException 2为 BusinessPromptException
     */
    private String errorType;
    /**
     * 简单的错误信息
     */
    private String errorMessage;
    /**
     * 详细的堆栈错误信息
     */
    private String detailErrorMessage;

    /**
     * 日志id
     */
    private String logid;
    /**
     * 异常发生时间
     */
    private String errDate;
    /**
     * 业务数据
     */
    private Object data;

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getDetailErrorMessage() {
        return detailErrorMessage;
    }

    public void setDetailErrorMessage(String detailErrorMessage) {
        this.detailErrorMessage = detailErrorMessage;
    }

    public String getErrDate() {
        return errDate;
    }

    public void setErrDate(String errDate) {
        this.errDate = errDate;
    }

    public String getLogid() {
        return logid;
    }

    public void setLogid(String logid) {
        this.logid = logid;
    }

    public String getErrorType() {
        return errorType;
    }

    public void setErrorType(String errorType) {
        this.errorType = errorType;
    }

    private ResultJson(Object data) {
        this.code = HttpServletResponse.SC_OK;
        this.data = data;
    }

    public ResultJson() {
    }

    private ResultJson(Integer code, String errorMessage) {
        this.status = "0";
        this.code = code;
        this.errorMessage = errorMessage;
    }

    public static ResultJson createError(Integer code, String errorMessage) {
        return new ResultJson(code, errorMessage);
    }

    public static ResultJson createSuccess(Object data) {
        return new ResultJson(data);
    }

}
